home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1998 August / PC Plus SuperCD 50a Issue 142 (CD142a) (August 1998).iso / trial / demon / TURNPIKE.1 / CLASSES.ZIP / sun / tools / ZIP / ZipReader.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-04-14  |  1.9 KB  |  99 lines

  1. package sun.tools.zip;
  2.  
  3. import java.io.IOException;
  4. import java.io.InputStream;
  5.  
  6. public class ZipReader implements ZipConstants {
  7.    // $FF: renamed from: is java.io.InputStream
  8.    private InputStream field_0;
  9.    // $FF: renamed from: ze sun.tools.zip.ZipEntry
  10.    private ZipEntry field_1;
  11.    private ZipReaderInputStream zis;
  12.    private byte[] lochdr = new byte[30];
  13.  
  14.    public ZipReader(InputStream var1) {
  15.       this.field_0 = var1;
  16.    }
  17.  
  18.    public boolean nextEntry() throws ZipFormatException, IOException {
  19.       if (this.field_0 == null) {
  20.          return false;
  21.       } else {
  22.          if (this.zis != null) {
  23.             while(this.zis.count > 0) {
  24.                this.zis.skip((long)this.zis.count);
  25.             }
  26.          }
  27.  
  28.          this.readFully(this.lochdr, 0, 4);
  29.          byte[] var1 = this.lochdr;
  30.          byte[] var2 = ZipConstants.LOCSIG;
  31.          if (!ZipFile.checkSig(var1, 0, var2)) {
  32.             var1 = this.lochdr;
  33.             var2 = ZipConstants.CENSIG;
  34.             if (ZipFile.checkSig(var1, 0, var2)) {
  35.                return false;
  36.             } else {
  37.                this.field_0 = null;
  38.                throw new ZipFormatException("Invalid LOC header signature");
  39.             }
  40.          } else {
  41.             this.readFully(this.lochdr, 4, 26);
  42.             var1 = this.lochdr;
  43.             if ((var1[8] & 255 | (var1[9] & 255) << 8) != 0) {
  44.                throw new ZipFormatException("Compressed entries not supported");
  45.             } else {
  46.                var1 = this.lochdr;
  47.                if (((var1[6] & 255 | (var1[7] & 255) << 8) & 1) == 1) {
  48.                   throw new ZipFormatException("Encrypted entries not supported");
  49.                } else {
  50.                   var1 = this.lochdr;
  51.                   var1 = new byte[var1[26] & 255 | (var1[27] & 255) << 8];
  52.                   this.readFully(var1, 0, var1.length);
  53.                   String var10 = new String(var1, 0, 0, var1.length);
  54.                   this.field_1 = new ZipEntry(var10);
  55.                   byte[] var3 = this.lochdr;
  56.                   this.field_1.length = (long)(var3[22] & 255 | (var3[23] & 255) << 8 | (var3[24] & 255 | (var3[25] & 255) << 8) << 16);
  57.                   var3 = this.lochdr;
  58.                   this.field_1.mtime = (long)(var3[12] & 255 | (var3[13] & 255) << 8 | (var3[14] & 255 | (var3[15] & 255) << 8) << 16);
  59.                   var3 = this.lochdr;
  60.                   long var14 = (long)(var3[28] & 255 | (var3[29] & 255) << 8);
  61.                   if (this.field_0.skip(var14) != var14 && true) {
  62.                      throw new ZipFormatException("Unexpected EOF");
  63.                   } else {
  64.                      this.zis = new ZipReaderInputStream(this.field_0, this.field_1);
  65.                      return true;
  66.                   }
  67.                }
  68.             }
  69.          }
  70.       }
  71.    }
  72.  
  73.    public ZipEntry getEntry() {
  74.       return this.field_1;
  75.    }
  76.  
  77.    public InputStream getInputStream() {
  78.       return this.zis;
  79.    }
  80.  
  81.    private boolean readFully(byte[] var1, int var2, int var3) throws IOException {
  82.       while(var3 > 0) {
  83.          int var4 = this.field_0.read(var1, var2, var3);
  84.          if (var4 == -1) {
  85.             return false;
  86.          }
  87.  
  88.          var2 += var4;
  89.          var3 -= var4;
  90.       }
  91.  
  92.       return true;
  93.    }
  94.  
  95.    private boolean skip(long var1) throws IOException {
  96.       return this.field_0.skip(var1) == var1;
  97.    }
  98. }
  99.